S R E V I N U Ite It Type-oriented Logic Meta Programming
نویسندگان
چکیده
code often only depends on interfaces and purposefully ignores the implementation details of a speci c class. Hence it should be possible to write abstract code independent of the class hierarchy. In most class-based languages this is impossible because method implementations are associated with a speci c class. Therefore, abstract code usually ends up in an abstract class which depends on subclasses to ll in the implementation details. Consider the abstract class in gure 1.2 implementing the Searchable interface for collections that provide a way of enumerating their elements. The problem with this abstract class is that it is unclear where to insert it into the class tree. The problem becomes exponentially worse when there are several abstract interface implementations. A better, more \Type-Oriented Programming" avored solution can be accomplished in some parametric type systems by simulating a mixin as a parametric class inheriting from one of its parameters. Not all parametric type systems allow inheriting from type parameters because of implementation-related restrictions. Pizza for one does not allow using a type parameter in this way. For the sake of the argument we nevertheless present a hypothetical mixin solution in Pizza syntax in gure 1.3. A \mixin class" is like a function which can create a subclass implementing the Searchable interface for any class meeting the required type constraint. The solution with a mixin is not ideal either. Sometimes we want to a ect the appropriate classes directly rather than through subclassing. In this case mixin classes will not work. Another problem with mixin classes is that the mixin's implementation should sometimes be dependent on the base class to provide a more e cient implementation in particular cases. As an example consider a collection which stores its elements in a hash-table. It would be more e cient to implement the SearchableMixin by hashing rather than by enumeration. We could try to accomplish Imperative languages have an if-then-else statement. Functional language provide an if as function. Logic languages can make decisions by \pattern matching". Etc. 1.6. MOTIVATING EXAMPLES 19 interface Enumerable { Enumeration elements(); } interface Enumeration { boolean hasMoreElements(); El next(); } abstract class Searchable< El implements Equality > implements Enumerable { boolean contains(El e) { boolean found = false; Enumeration elems = elements(); while (!found && (elems.hasMoreElements())) found = e.equal(elems.next()); return found; } } Figure 1.2: Abstract Class Implementation of Searchable class SearchableMixin > > extends Super implements Searchable { boolean contains(El e) { ... } } Figure 1.3: Mixin implementation of Searchable 20 CHAPTER
منابع مشابه
Amitraz Poisoning; A case study
A m i t r a z, a n i ns e c t i c i d e /a ca ri c i de of the f o r m a m i d i n e p e st i c i d e s group, is a ? 2 a d r e n e r g i c ag on i st a nd of t he a m i d i ne c h e m i ca l f a m il y generally us e d to c o n t r ol animal e c top a r a s i t e s. Poisoning due to am i t r a z i s r a r e and character...
متن کاملA Deductive and Typed Object-Oriented Language
1 I n t r o d u c t i o n a n d r e s u l t s In the last decade, the merge of object-oriented programming with object-oriented data structuring principles has lead to a rapid increasement of new developments in the field of databases and logical languages. Object-oriented databases have the advantages of a clean conceptual design as well as the possibility of enforcing better software engineer...
متن کاملA Logic Program Schema and Its Applications
In t h i s paper we cons ide r a . spec i f i c type of l o g i c programs ca l led recursive-schema programs and show t h a t the c l ass of r ecu rs i ve -schema programs has s u f f i c i e n t e x p r e s s i v e c a p a b i l i t y , which provides an a l t e r n a t i v e simple proof fo r the resultby Tarnlund concerning the computat ional power of Horn c lause programs. F u r t h e r , ...
متن کاملLogic for Part-of-Speech Tagging and Shallow Parsing
I n -fliis p ap er, a p u re ly log ical approach to p a rt-o f-sp eec h tag g in g an d sh a llo w p a rs in g is exp lo red . I t h as a lo t in co m m o n w ith red u c tio n is t p a rs in g s tra teg ies such as th o se em p lo y ed in C o n stra in t G ram m ar (K arlsso n e t al. 1994) an d F in ite -S ta te In te rsec tio n G ram m ar (K o sk en n iem i 1990), b u t ru les are fo rm u l...
متن کاملThe working life of a group of nurses.
H ier w o rd ’n o o r s ig g e g e e v a n d ie loop b an e v a n d ie 139 g ereg istreerd e v erp leeg k u n d ig es w a t’n B .S o c .S c . (V erp leeg k u n d e) graad aan d ie U n iv e r s ite it v a n N a ta l b eh a a l het. V an die p o te n s ië le 981 w erk ja re w a t h ierd ie gegra d u eerd es so u k o n g ew erk h et, is 551 jaar (56,2%) m et v e r p le e g w e r k d eu rg eb rin g...
متن کاملA LOGIC-ORIENTED ATN Grammar Knowledge as Part of the System's Knowledge
1 This system has been developed i n the p r o j e c t "Automa t i sehe E r s t e l l u n g eemant i scher Hetze" (Automatic c o n s t r u c t i on of e m a n t i c networks) a t the I n s t i t u t e of App l i ed Compuger Scienoe a t the Techn ica l U n i v e r s i t y of B e r l i n . The pro~ee t was suppor ted by the M i n i s t r y f o r Sc ience and Technology (BMFT) of the F e d e r a l...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
عنوان ژورنال:
دوره شماره
صفحات -
تاریخ انتشار 1998